package com.dhl.single;


public class 静态内部类 {
    public static void main(String[] args) {
        SingleStaticInsideClass instance = SingleStaticInsideClass.getInstance();
        SingleStaticInsideClass instance1 = SingleStaticInsideClass.getInstance();
        System.out.println(instance1 == instance);
    }

}
class SingleStaticInsideClass{
    /**
     * 构造器私有化
     */
    private SingleStaticInsideClass() {

    }

    /**
     * 静态内部类
     */
    static class SingleStaticClassInstance{
        /**
         * 创建静态变量
         */
        private static final SingleStaticInsideClass instance = new SingleStaticInsideClass();
    }
    /**
     * 返回对象
     */
    public static SingleStaticInsideClass getInstance(){
        return SingleStaticClassInstance.instance;
    }

}
